local thbattle__xiangzi_gongzhen = fk.CreateSkill {

  name = "thbattle__xiangzi_gongzhen",

  tags = {},

}



thbattle__xiangzi_gongzhen:addEffect(fk.CardEffectFinished, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(thbattle__xiangzi_gongzhen.name) and data.card and
        data.card.trueName == "slash" and
        data.from == player
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(player), function(p)
      return not p:isProhibited(target, Fk:cloneCard("slash")) and p ~= target
    end)
    if #targets > 0 then
      if room:askForSkillInvoke(player, thbattle__xiangzi_gongzhen.name, nil, "#thbattle__xiangzi_gongzhen::" .. target.id) then
        local targetPlayer =room:askToChoosePlayers(player,{
          targets=targets,
          min_num=1,
          max_num=1,
          prompt="#thbattle__xiangzi_gongzhen-choose_player::"..target.id,
          skill_name=thbattle__xiangzi_gongzhen.name,
          cancelable=true
        })
        if #targetPlayer > 0 then
          event:setCostData(self, targetPlayer[1])
          return true
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targetPlayer = event:getCostData(self)
    local use = player.room:askToUseCard(targetPlayer, {
      pattern = "slash",
      prompt = "#thbattle__xiangzi_gongzhen-use_slash::" .. target.id,
      cancelable = true,
      extra_data = { bypass_times = true, bypass_distances = true, must_targets = { target.id } },
      skill_name = thbattle__xiangzi_gongzhen.name
    })
    if use then
      room:useCard(use)
    end
  end,
})

return thbattle__xiangzi_gongzhen
